package oop.类和方法和构造器;

/**
 * @ClassName : Person
 * @Author : LV88VL
 * @Date: 2021/2/4 12:40
 * @Description : 构造器、封装、继承
 */
public class Person {
    protected String name="king";
    private int age;
    private String sex;
    private  int dao;

    //构造器====构造函数  调用有参构造方法必须将无参构造方法声明
    //相当于重载
     public Person() {

    }
    public Person(String name, int age, String sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
    }
    public void extand(){
        System.out.println( this.name+"正在扩张领土");
    }

    public int getDao() {
        return dao;
    }

    public void setDao(int dao) {
        this.dao = dao;
    }

    //封装使用get、set方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }
}
